package com.thh.design.factory;


/**
 * @ClassName CarSimpleFactory
 * @Description 简单工厂模式
 * @Author thh
 * @Date 21:11 2021/01/13
 **/
public class CarSimpleFactory {
    /**
     * 车档类型
     */
    public static final String UP_TYPE = "upType";

    public static final String MID_TYPE = "midType";

    public static final String DN_TYPE = "dnType";

    /**
     * 创建汽车
     * @param type
     * @return
     */
    public static ICar create(String type){
        ICar car = null;
        if (UP_TYPE.equals(type)){
            car = new UpCar();
        }else if (MID_TYPE.equals(type)){
            car = new MidCar();
        }else if (DN_TYPE.equals(type)){
            car = new DnCar();
        }
        return car;
    }
}
